package test;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.util.Arrays;

/**
 * @Program:IntelliJ IDEA
 * @description:
 * @author:香蕉你个啵娜娜 l.h-p@qq.com
 * @create:2023-01-11 21:39
 **/

public class test {
    public static void main(final String[] args) throws IOException {
        System.out.println("hello");
        final DatagramPacket receive = new DatagramPacket(new byte[1024], 1024);
        final DatagramSocket server = new DatagramSocket(8989);

        System.out.println("---------------------------------");
        System.out.println("Server current start......");
        System.out.println("---------------------------------");

        while (true) {
            server.receive(receive);

            final byte[] recvByte = Arrays.copyOfRange(receive.getData(), 0,
                    receive.getLength());

            System.out.println("Server receive msg:" + new String(recvByte));
        }

    }
}
